fix: repair failing tests and type errors across api and shared packages - #111
Open
stooit wants to merge 1 commit into
Open
fix: repair failing tests and type errors across api and shared packages#111stooit wants to merge 1 commit into
stooit wants to merge 1 commit into
Conversation
- Implement paginate() utility in shared package (was a throwing stub) - Fix auth middleware case-sensitivity on public HTTP methods (post -> POST, normalise with toUpperCase) - Add missing badRequest import in users route - Align shared User type field userName -> username to match tests and consumers - Set tsconfig types to bun-types so bun:test/process resolve
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
Fixes all failing tests and eliminates all type errors.
bun test→ 22 pass / 0 fail;bunx tsc --noEmit→ exit 0.Changes
shared/src/utils/pagination.ts— implementedpaginate()(was a stub throwingnot implemented). Handles page slicing,total/totalPages, out-of-range pages (emptydata, truthful metadata), and empty arrays; guardspageSize > 0.api/src/middleware/auth.ts— fixed case-sensitivity bug on public HTTP methods (normalisesc.req.method.toUpperCase()), soPOST /usersis correctly public while PUT/DELETE/PATCH still require a token.api/src/routes/users.ts— added missingbadRequestimport (was a runtimeReferenceErroron invalidPOST /users).shared/src/types.ts— alignedUserfielduserName→usernameto match tests and all consumers.tsconfig.json— settypes: ["bun-types"]sobun:testandprocessresolve (bun-typesalready a devDependency; no new deps).Assumptions
Verification
bun test→ 22 pass, 0 fail (4 files, 37 assertions)bunx tsc --noEmit→ clean